package com.nf.db.handlers;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import static com.nf.db.handlers.RowProcessor.DEFAULT_ROWPROCESSOR;

/*
 * 让ResultSetHandler处理结果集，并将结果集转换为Map集合
 * */
public class MapHandler implements ResultSetHandler<Map<String, Object>> {
    @Override
    public Map<String, Object> handle(ResultSet rs) throws SQLException {

      return rs.next()?DEFAULT_ROWPROCESSOR.toMap(rs):new HashMap<>();
    }
}
